Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

413
Visualizações
Query multiple fields with same value [GraphQL][Amplify]

I'm creating an API with AWS Amplify and AppSync GraphQL. I Work on a Tinder like App.

I would like to search the same value in two fields for a Query. I've tried a lot of solutions, but none seems to work.

I have a User @Model which is connected to many Match via @connection

type User @model
  @auth(rules: [{allow: public}])

    {
      id: ID!
      email: String!
      password: String
      age: String!
      name: String!
      description: String
      pickupLine: String
      orientation: Orientation!
      gender: Gender! 
      animal: Animal!
      profilePicture: String!
      pictures: [String]!
      location: Location
      numberOfSparksAvailable: Int!
      matchs: [Match]
        @connection(keyName: "byUser", fields: ["id"])
      sparks: [Spark]
        @connection(keyName: "byUser", fields: ["id"])
    }

And I have a Match @Model which have a senderId field and a receiverId field

type Match @model
  @auth(rules: [{allow: public}])
  
  @key(name: "byUser", fields: ["receiverId", "senderId"], queryField: "matchByUser")
  @key(name: "bySender", fields: ["senderId"], queryField: "sparkBySender")
  @key(name: "byReceiver", fields: ["receiverId"], queryField: "sparkByReceiver")
    {
      id: ID!
      status: MatchStatus!
      matchType: MatchType
      sender: User! @connection(fields: ["senderId"])
      senderId: ID!
      receiver: User! @connection(fields: ["receiverId"])
      receiverId: ID!
      answerFrom: Answer!
      answerTo: Answer
      chatRoomId: ID!
      chatRoom: ChatRoom!
        @connection(fields: ["chatRoomId"])
      deletedAt: AWSDate
    }

And and I don't find any way to make bySender @key look for both senderId and receiverId. I want to be able to have all the Matches for a User whether he's the receiver or the sender.

But when I make a Query to ListUsers I only get the Matches where the User is a receiver.

I've also tried to make multiple @connection but it is not allowed by Graphql-transformer.

I also tried to make an usersId: [ID!]! like that

type Match @model {
  ...
  usersId: [ID!]!
  users: [User!]!
    @connection(fields: ["usersId"])
  ...
}

But It's also not allowed by graphql-transformer..

Has anyone a solution to get all the matches for a User?

Thanks a lot !

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda